package system.student.funtion.context;

import system.student.entity.user.UserInfo;
import system.student.entity.user.UserType;
import system.student.login.SignupStrategy;
import system.student.login.impl.StudentSignupStrategyImpl;
import system.student.login.impl.TeacherSignupStrategyImpl;

import java.util.HashMap;

public class SignupStrategyContext {
    private static final HashMap<UserType,SignupStrategy> map = new HashMap<>();

    static {
        map.put(UserType.Teacher, new TeacherSignupStrategyImpl());
        map.put(UserType.Student, new StudentSignupStrategyImpl());
    }

    public void signup(UserInfo userInfo) {
        UserType userType = userInfo.getUserType();
        SignupStrategy signupStrategy = map.get(userType);
        if (signupStrategy != null) {
            signupStrategy.signup(userInfo);
        }else {
            System.out.println("暂不支持");
        }
    }
}
